package com.ideaaedi.springcloud.jd.commonspring.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ideaaedi.springcloud.jd.commonds.entity.user.bo.ApiInfoBO;
import com.ideaaedi.springcloud.jd.commonds.entity.user.po.SysApiResourcePO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.lang.NonNull;

import java.util.Set;

/**
 * <p>
 * 系统-api资源表 Mapper 接口
 * </p>
 *
 * @author <font size = "20" color = "#3CAA3C"><a href="https://gitee.com/JustryDeng">JustryDeng</a></font> <img src="https://gitee.com/JustryDeng/shared-files/raw/master/JustryDeng/avatar.jpg" />
 * @since 2021.0.5.B
 */
@Mapper
public interface SysApiResourceMapper extends BaseMapper<SysApiResourcePO> {
    
    /**
     * 根据角色查询可访问的api
     *
     * @param roleIds 角色id集合
     * @return 可访问的api
     */
    Set<ApiInfoBO> selectApiByRoleIds(@NonNull @Param("roleIds") Set<Long> roleIds);
    
    /**
     * 根据用户id查询可访问的api
     *
     * @param userId 用户id
     * @return 可访问的api
     */
    Set<ApiInfoBO> selectApiByUserId(@NonNull @Param("userId") Long userId);
    
    /**
     * 根据角色查询可访问的api id
     *
     * @param roleIds 角色id集合
     * @return 可访问的api id
     */
    Set<Long> selectApiIdByRoleIds(@NonNull @Param("roleIds") Set<Long> roleIds);
}
